package com.taru.order.service;



import com.taru.order.common.Data;
import com.taru.order.dao.NoteDaoImpl;
import com.taru.order.entity.Note;
import com.taru.order.entity.NoteLikes;

import java.io.IOException;
import java.util.List;

public class NoteServiceImpl {

    NoteDaoImpl noteDao=new NoteDaoImpl();


    public int addNote(Note note)  {

        return noteDao.addNote(note);
    }


    public int modNote(Note note)  {

        return noteDao.modNote(note);
    }

    public int removeNotes(List list)  {

        return noteDao.removeNotes(list);
    }

    public Data listNotes(Integer pageNum, Integer pageSize)  {
        List<Note> noteList=noteDao.listNotes(pageNum,pageSize);
        Long toralCount=noteDao.queryToral();
        Data data=new Data();
        data.setTotalCount(toralCount);
        data.setTotalPage(toralCount,pageSize);
        data.setPageNum(pageNum);
        data.setPageSize(pageSize);
        data.setList(noteList);
        return data;

    }

    public int inNoteLikes(NoteLikes likes)  {
        int code=noteDao.insertNoteLikes(likes);
        return code;
    }

    public int outNoteLikes(NoteLikes likes)  {
        int code=noteDao.deleteNoteLikes(likes);
        noteDao.deletedLikes(likes);
        return code;
    }
    /**
     * 判断有没有被点赞过
     */
    public NoteLikes queryNoteLikes(NoteLikes likes)  {
        NoteLikes likes1=noteDao.queryNoteLikes(likes);
        return likes1;
    }

    public Note getNoteById(String id)  {

        return noteDao.getNoteById(id);
    }

    public List<Note> getNoteByUserId(String userId) {

        return noteDao.getNoteByUserId(userId);
    }

    public List<Note> getNoteByYearMonth(String year,String month) {

        return noteDao.getNoteByYearMonth(year,month);
    }
}
